package com.spoto.oa.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.spoto.oa.dao.CustomerDAO;
import com.spoto.oa.dao.impl.CustomerDAOImpl;
import com.spoto.oa.model.Customer;
import com.spoto.oa.service.CustomerServ;
/**
 * 
 * @Project: OA
 * @Description: 客户管理模块功能服务的具体实现
 * @Author: LinYiSong
 * @Vesion: 
 * @Date: 2010-10-24~2010-10-24
 */
public class CustomerServImpl implements CustomerServ {
	CustomerDAO customerDAO=new CustomerDAOImpl();
	/**
	 * 新增客户
	 * @param customer
	 * @throws SQLException 
	 */
	public void addCustomer(Customer customer) throws SQLException {
		customerDAO.save(customer);
	}
	/**
	 * 取得所有的客户信息
	 */
	public List<Customer> getAllCustomers() {
		return customerDAO.getAll();
	}
	/**
	 * 根据客户名称去取得客户信息
	 * @param name
	 * @return
	 */
	public Customer getCustomerByName(String name) {
		return customerDAO.getByName(name);
	}
	/**
	 * 修改客户信息
	 * @param customer
	 */
	public void updateCustomer(Customer customer) {
		customerDAO.update(customer);
		
	}
	/**
	 * 根据客户名称删除客户信息
	 * @param name
	 */
	public void deleteCustomerByName(String name) {
		customerDAO.deleteByName(name);
	}
	/**
	 * 根据客户名称模糊搜索
	 * @param infor
	 * @return
	 */
	public List<Customer> searchCustomersByName(String name) {
		return customerDAO.getAllByName(name);
	}
	/**
	 * 根据公司名称模糊搜索
	 * @param infor
	 * @return
	 */
	public List<Customer> searchCustomersByCompany(String company) {
		return customerDAO.getAllByCompany(company);
	}
	/**
	 * 根据重要程度模糊搜索
	 * @param infor
	 * @return
	 */
	public List<Customer> searchCustomersByLevel(int level) {
		return customerDAO.getAllByLevel(level);
	}
	/**
	 * 根据手机号码模糊搜索
	 * @param parseInt
	 * @return
	 */
	public List<Customer> searchCustomersByMobile(int mobile) {
		return customerDAO.getAllByMobile(mobile);
	}
	/**
	 * 发生导入数据冲突时往冲突表中添加冲突客户记录
	 * @param customer
	 */
	public void addCustomerConfict(Customer customer) {
		customerDAO.saveConflict(customer);
		
	}
	/**
	 * 根据冲突名取得冲突数据
	 * @param name
	 * @return
	 */
	public Customer getByNameConfict(String name) {
		return customerDAO.getByNameConfict(name);
	}
	/**
	 * 根据冲突名删除冲突数据
	 * @param customer
	 */
	public void deleteCustomerConfictByName(String name) {
		customerDAO.deleteConfictByName(name);		
	}
	/**
	 * 取得所有的冲突数据
	 * @return
	 */
	public List<Customer> getAllCustomersConfict() {
		return customerDAO.getAllConfict();
	}
	
	

}
